﻿/*
 * Twipler - Twitter Web Client with features.
 *  
 *  Copyright (C) 2010. Ian Quigley
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details. 
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 */

using System.Collections.Specialized;
using Twipler.App.AsyncCommands;

namespace Twipler.App
{
    public abstract class AsyncCommand
    {
        public abstract string Render();

        public static AsyncCommand Get(NameValueCollection queryString)
        {
            string commandName = queryString["cmd"];

            if (string.IsNullOrEmpty(commandName))
                return new UnknownCommand();

            switch (commandName.ToLower())
            {
                case "delay":
                    return new DelayedRenderCommand(queryString);

				case "suggest":
					return new SuggestNameCommand(queryString);

				case "action":
					return new ActionCommand(queryString);
                
                default:
                    return new UnknownCommand();
            }
        }
    }

	public class UnknownCommand : AsyncCommand
    {
        public override string Render()
        {
            return "Unknown command";
        }
    }
}
